package io.renren.modules.generator.controller;

import io.renren.common.utils.R;
import io.renren.modules.generator.entity.vo.TreeViewVo;
import io.renren.modules.generator.entity.vo.TreeViewVoTest;
import io.renren.modules.generator.service.EmployeeInfoService;
import io.renren.modules.generator.service.GeneratorDepartmentService;
import io.renren.modules.generator.service.GeneratorGroupsService;
import io.renren.modules.generator.service.GeneratorRolesService;
import io.renren.modules.sys.controller.AbstractController;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


/**
 *
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-11-01 10:28:14
 */
@RestController
@RequestMapping("/generator/treeView")
public class TreeViewController extends AbstractController {
    @Autowired
    private EmployeeInfoService employeeInfoService;
    @Autowired
    private SysUserRoleService sysUserRoleService;
    @Autowired
    private SysRoleService  sysRoleService;
    @Autowired
    private SysUserService sysUserService;
    @Autowired
    private GeneratorRolesService generatorRolesService;
    @Autowired
    private GeneratorDepartmentService generatorDepartmentService;
    @Autowired
    private GeneratorGroupsService generatorGroupsService;

    /**
     * 展示组织架构  权限存在问题 ，requiresPermissions需要添加
     */
    @RequestMapping("/list")
    //@RequiresPermissions("generator:employeeinfo:list")
    public R list(){
        List<TreeViewVo> childNode = employeeInfoService.listByParentId(0l);
     return R.ok().put("childNode", childNode);
    }

/*
    @RequestMapping("/treeView")
    public R elist(){


     List<TreeViewVoTest> list = new ArrayList<>();

        TreeViewVoTest treeViewVoTest = new TreeViewVoTest();
       treeViewVoTest.setUsername("    第一级 第一个节点 ");
        TreeViewVoTest treeViewVoTest1 = new TreeViewVoTest();
        treeViewVoTest.setUsername(" 第二级 第二个节点");
        treeViewVoTest.getChildNode().add(treeViewVoTest1);
        TreeViewVoTest treeViewVoTest2 = new TreeViewVoTest();
        treeViewVoTest.setUsername("  第二级 第一个节点");
        treeViewVoTest.getChildNode().add(treeViewVoTest2);
        TreeViewVoTest treeViewVoTest3 = new TreeViewVoTest();
        treeViewVoTest.setUsername("  第三级 第一个节点");
        treeViewVoTest1.getChildNode().add(treeViewVoTest3);
        list.add(treeViewVoTest);
        return  R.ok().put("list",list);
    }
*/








}
